#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

const double exp=1e-5;
int t;
double d[100005],a[100005],v[100005],p[100005];
double mins=100861145,maxe;
double cal(double v1,double v2,double a)
{
	return (v1*v1-v2*v2)/(2*a);
}

int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--)
	{
		int n,m;
		double l,V;
		cin>>n>>m>>l>>V;
		for(int i=1;i<=n;i++)
		{
			cin>>d[i]>>v[i]>>a[i];
		}
		for(int i=1;i<=m;i++)
		{
			cin>>p[i];
		}
		int cnt=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==0)
			{
				if(v[i]<=V)
					continue;
				else
				{
					if(d[i]<=p[m])
						cnt++;
					maxe=l;
				}
			}
			else if(a[i]<0)
			{
				if(v[i]<=V)
					continue;
				else
				{
					if(d[i]+cal(v[i],V,a[i])<=l)
					{
						if(d[i]<=p[m] && d[i]+cal(v[i],V,a[i])>p[1])
							if(p[lower_bound(p+1,p+m+1,d[i])-p]<=p[upper_bound(p+1,p+m+1,d[i]+cal(v[i],V,a[i]),less<double>())-p])
								cnt++;
						maxe=max(maxe,d[i]+cal(v[i],V,a[i]));
					}
				}
			}
			else
			{
				double c=cal(v[i],V,a[i]);
				if(v[i]>V)
				{
					if(d[i]<=p[m])
						cnt++;
					maxe=l;
				}
				else
				{
					if(d[i]+c<=l)
					{
						if(d[i]<=p[m] && d[i]+c>p[1])
							if(p[lower_bound(p+1,p+m+1,d[i])-p]<=p[upper_bound(p+1,p+m+1,d[i]+c,less<double>())-p])
								cnt++;
						mins=min(mins,d[i]+cal(v[i],V,a[i]));
					}
				}
			}
		}
		cout<<cnt<<' ';
		int s=1,e=m;
		if(mins<=p[m])	s=lower_bound(p+1,p+m+1,mins)-p;
		if(maxe>p[1])	e=upper_bound(p+1,p+m+1,maxe,less<double>())-p;
		cout<<m-(e-s+1)<<endl;
	}
	return 0;
}
